<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="../assets/js/vue.js"></script>
    <link rel="stylesheet" href="../assets/css/index.css"/>
</head>
<body>
<h1>Vue.set</h1>
<hr>
<div id="app">
    <ul>
        <li v-for="dat in goods">
            {{dat.name}} - {{dat.num}}
        </li>
    </ul>
    <p>总计：{{count}}</p>
    <p>
        <button @click="qingkong">clean</button>
    </p>
</div>
<button onclick="add()">+</button>

<script>
    function add() {
//        Vue.set(vdata, 'count', '4')
        //set基本不用，尽量不要用

        vdata.goods.push({name: 'house', num: '1'})

        vm.count++
    }

    var vdata = {
        count: 3,
        goods: [
            {name: 'car', num: '1'},
            {name: 'pen', num: '2'}
        ]
    };

    var vm = new Vue({
        el: '#app',
        data: vdata,
        methods: {
            qingkong: function () {
                this.count = 0;
                this.goods = [];
            }
        }
    });


</script>
</body>
</html>